<template>
  <el-dialog v-model="dialog.visible" :title="dialog.title" width="80%" @close="handleCloseDialog">
    <el-form :model="formData" :rules="rules" ref="formRef" label-width="100px">
      <el-form-item label="驳回原因" prop="remark">
        <el-input
          v-model="formData.remark"
          type="textarea"
          :rows="4"
          placeholder="请输入驳回原因"
          maxlength="200"
        />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button type="primary" @click="handleSubmit">确定</el-button>
        <el-button @click="handleCloseDialog">取 消</el-button>
      </div>
    </template>
  </el-dialog>
</template>
<script setup>
const emit = defineEmits(["auditOrder"]);
const dialog = reactive({
  title: "",
  visible: false,
});
// 关闭弹窗
function handleCloseDialog() {
  dialog.visible = false;
}

function showModal(data) {
  dialog.visible = true;
}
const formRef = ref();
const formData = reactive({
  remark: "",
});
const rules = reactive({
  remark: [{ required: true, message: "请输入驳回原因", trigger: "blur" }],
});
const handleSubmit = () => {
  console.log(formData);
  formRef.value.validate((valid) => {
    if (valid) {
      emit("auditOrder", formData.remark); // 关闭弹窗
      handleCloseDialog();
    }
  });
};
defineExpose({
  showModal,
});
</script>
<style style="scss" scoped>
.order-detail-container {
  padding: 10px 10px 30px;
}
.points-price {
  color: #f56c6c;
}
</style>
